<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page import="com.lanju.model.SAModel" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	SAModel m=(SAModel)request.getSession().getAttribute("saModel");
	String name = request.getSession().getAttribute("saModel")==null ? "":m.getAdminName();
	String adminCode = request.getSession().getAttribute("saModel")==null ? "":m.getAdminCode();
	Integer f = request.getSession().getAttribute("saModel")==null ? 0:m.getFlag();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > 

<html>
<head>
<base href="<%=basePath%>">
<title>财务报表列表</title>
<link rel="stylesheet" type="text/css" href="./js/bootstrap-3.3.5-dist/css/bootstrap.css" />
<link href="./js/metisMenu/metisMenu.min.css" rel="stylesheet">
<link href="./css/sb-admin/sb-admin-2.css" rel="stylesheet">
<link rel="stylesheet" href="./js/font-awesome/css/font-awesome.min.css">
<link href="./css/base.css" rel="stylesheet">
<link rel="stylesheet" href="./js/bootstrap-table/bootstrap-table.min.css">
<link rel="stylesheet" href="./js/bootstrap-multiselect/bootstrap-multiselect.css"/>
<link rel="stylesheet" href="./js/bootstrap-3.3.5-dist/css/bootstrap-datetimepicker.css">
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-all.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="./js/metisMenu/metisMenu.js"></script>
<script src="./js/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="./js/bootstrap-jquery-plugin/jquery.bootstrap.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="./js/xss.js"></script>
<script src="./js/ajaxfileupload.js"></script>
<style type="text/css">
.fileinput-button {
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.fileinput-button input{
    position:absolute;
    right: 0px;
    top: 0px;
    opacity: 0;
    -ms-filter: 'alpha(opacity=0)';
    font-size: 200px;
}
.btn-upload{
    border: 1px solid #efefef;
    border-radius: 6px;
    padding: 8px;
    color: #fff;
    background-color: #04be02;
}
table tbody tr td dl{
  border-bottom: 1px solid #F5F5F5;
}
</style>
</head>
<body>
<%-- <jsp:include page="../template/head.jsp" />
<jsp:include page="../template/leftnav.jsp" /> --%>
<div id="page-wrapper">
	<div>
		<h4>首页>>报表列表</h4>
	</div>
	<div class="content">
		<form class="form-inline">
			<div class="form-group">
 					<button id="export" class="btn btn-default">导出Excel</button>
			</div>
			
		</form>
		 <div align="center">
			<table cellpadding="1" cellspacing="1" width="100%"  class="table table-striped">
				<thead class="headTr">
					<tr>
<!-- 						<th style="text-align: center;">行影活动路线</th> -->
						<th style="text-align: center;">活动套餐</th>
<!-- 						<th style="text-align: center;">有赞订单</th> -->
<!-- 						<th style="text-align: center;">各路线总数</th> -->
						<th style="text-align: center;">最终人数</th>
						<th style="text-align: center;">原订单人数</th>
						<th style="text-align: center;">转出人数</th>
						<th style="text-align: center;">转入人数</th>
						<th style="text-align: center;">退款人数</th>
						<th style="text-align: center;">最终收入</th>
					</tr>
				</thead>
				<tbody id="content">
					<tr style='background-color :#c0c0c0'>
				<td colspan="7" style="text-align: center;">数据加载中...</td>
                    <td style="text-align: center;"><dl>2</dl></td>
                    <td style="text-align: center;"><dl>0</dl></td>
                    <td style="text-align: center;"><dl>0</dl></td>
                    <td style="text-align: center;"><dl>2</dl></td>
                    <td style="text-align: center;"><dl>0</dl></td>
                    <td style="text-align: center;"><dl>0</dl></td>
                 </tr>	
					
				</tbody>
				
			</table>
		    </div>
    </div>
</div>
   	
<script>
var interestPic1 = '';
var interestPic2 = '';
var flag11 = "<%=adminCode %>";
var flag12 = "<%=f %>";
$(function () {
	
	"use strict";

	$('#search').on('click', function (e) {
		e.preventDefault();
		searchOrder();
	});
	$('#export').on('click', function (e) {
		e.preventDefault();
		window.location.href="./activity/exportActivity?type=1";
	});
	loadData();

});
function loadData(){
	$.ajax({
		url : "./activity/getSelfActivityList",
		type : 'POST',
		dataType : 'json',
		data :{ type: 1},
		success : function(ret) {
		var html="";
		$("#content").html("");
		if(ret.routeList.rows != null ){
			var data=ret.routeList.rows;
			var totalNumTtotal=0;
			var eachRouteNum=0;
			var greatOrderTotal=0;
			var actualNumTotal=0;
			var drawbackTotal=0;
			var changRouteTotal=0;
			var comeInTotal=0;
			var normalTotal=0;
			var fianal_incomTotal=0;
			for (var i in data) {
				html+="<tr>";
				html+="<td style='text-align: center;'>";
				var schHtml="";
				var actualNumHtml="";
				var greatOrderHtml="";
				var determinedHtml="";//待定
				var waitderHtml="";
				var totalNumHtml="";
				var activeHtml="";
				var drawbackHtml="";
				var changRouteHtml="";
				var comeInHtml="";
				var normalHtml="";
				var fianal_incomHtml="";
				for(var j=0;j< data[i].length;j++){
					schHtml+="<dl>"+data[i][j].schedule+"</dl>";
					activeHtml+="<dl>"+data[i][j].mealName+"</dl>";
					actualNumHtml+="<dl>"+data[i][j].actualNum+"</dl>";
					actualNumTotal+=data[i][j].actualNum;
// 					greatOrderHtml+="<dl>"+data[i][j].greatOrder+"</dl>";
// 					greatOrderTotal+=data[i][j].greatOrder;
					determinedHtml+="<dl>-</dl>";
					totalNumHtml+="<dl>"+data[i][j].totalNum+"</dl>";
					totalNumTtotal+=data[i][j].totalNum;
					normalHtml+="<dl>"+data[i][j].normalCount+"</dl>";
					normalTotal+=data[i][j].normalCount;
					drawbackHtml +="<dl>"+data[i][j].drawbackNum+"</dl>";
					drawbackTotal+=data[i][j].drawbackNum;
					changRouteHtml+="<dl>"+data[i][j].changRouteNum+"</dl>";
					changRouteTotal+=data[i][j].changRouteNum;
					comeInHtml +="<dl>"+data[i][j].comeInNum+"</dl>";
					comeInTotal+=data[i][j].comeInNum;
				}
				html+=activeHtml;
				html+="</td>";
// 				html+="<td style='text-align: center;'>";
// 				html+=greatOrderHtml;
// 				html+="</td>";
// 				html+="<td style='text-align: center;vertical-align : middle'>"+data[i][0].eachtotalNum;
// 				eachRouteNum+=data[i][0].eachtotalNum;
// 				html+="</td>";
				html+="<td style='text-align: center;'>";
				html+=totalNumHtml;
				html+="</td>";
				html+="<td style='text-align: center;'>";
				html+=normalHtml;
				html+="</td>";
				html+="<td style='text-align: center;'>";
				html+=changRouteHtml;
				html+="</td>";
				html+="<td style='text-align: center;'>";
				html+=comeInHtml;
				html+="</td>";
				html+="<td style='text-align: center;'>";
				html+=drawbackHtml;
				html+="</td>";
			}
			html+="<tr style='background-color :#c0c0c0'><td colspan='1' style='text-align: center'>2018活动报名合计";
			html+="</td>";
// 			html+="<td style='text-align: center;'>"+greatOrderTotal;
// 			html+="</td>";
// 			html+="<td style='text-align: center;vertical-align : middle'>"+eachRouteNum;
// 			html+="</td>";
			html+="<td style='text-align: center;'>"+totalNumTtotal;
			html+="</td>";
			html+="<td style='text-align: center;'>"+normalTotal;
			html+="</td>";
			html+="<td style='text-align: center;'>"+changRouteTotal;
			html+="</td>";
			html+="<td style='text-align: center;'>"+comeInTotal;
			html+="</td>";
			html+="<td style='text-align: center;'>"+drawbackTotal;
			html+="</td>";
			html+="<td style='text-align: center;'>"+drawbackTotal;
			html+="</td>";
			html+="</tr>";
			
			$("#content").html(html);
		}else{
			$("#content").html("<tr><td colspan=\"7\" style=\"text-align: center;\">暂无数据...</td></tr>");
		}
		
		}
	});
}
function tableQueryParams(params) {
	var queryObj = getQueryObject();
	var newParams = $.extend(params,queryObj);
	return newParams;
}
	
function getQueryObject(){
	var queryObj;
	var cusName = $("#cusName").val();
	var phone = $("#phone").val();
	var idCard = $("#idCard").val();
	var queryObj = {
		    isSearch: true,
			name : cusName,
			phone : phone,
			idCard :idCard
		}
	
	if(cusName ==""){
		delete queryObj.name;
	}
	if(phone ==""){
		delete queryObj.phone;
	}
	if(idCard ==""){
		delete queryObj.idCard;
	}
	
	return queryObj;
}
	
function searchOrder(){
	var queryObj = getQueryObject();
	$('#table').bootstrapTable('refresh', {
		query : {
			offset: 0
		},
		url : "./order/getOrderList",
		silent : true
	});
}


function operFormatter(value, row) {
	console.log(row);
	var operTemp = $("#customerTemp").clone();
	var lis = operTemp.find("ul li");
	lis.eq(0).find("a").attr("href", "./jsp/order/editorder.jsp?id="+row.id);
// 	lis.eq(1).find("a").attr("onClick", "drawback(\""+row.id+"\",\""+row.customerModel.cusName+"\")");
	return operTemp.html();
}




function clearParm1(){

	$("#birth1").val('');
	$("#note1").val('');
	$("#phone1").val('');
    $("#name1").val('');

}

function dateFormatter(value, row){
	if(value!=null){
		return getSmpFormatDateByLong(value, true);
	}else{
		return '-';
	}
}
function nameFormatter(value, row){
	return row.customerModel.cusName;
}
function idCardNumFormatter(value, row){
	return row.customerModel.idCard;
}
function phoneFormatter(value, row){
	return row.customerModel.phone;
}
function routeFormatter(value, row){
	return row.routeModel.routeName;
}
function stateFormatter(value, row){
	if(value==0){
		return "<span style=\"color:#c7254e\"><span class=\"glyphicon glyphicon-ban-circle\" aria-hidden=\"true\"></span>删除</span>";
	}else{
		return "<span style=\"color:#5bc0de\"><span class=\"glyphicon glyphicon-play-circle\" aria-hidden=\"true\"></span>正常</span>";
	}
}


</script>
</body>
</html>